home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
051-075
/
scopedisk62
/
pipe203
/
read1006.c
< prev
Wrap
C/C++ Source or Header
|
1995-03-19
|
784b
|
41 lines
/*
* READ1006.C
*
* READ1006 name
*
* Open file with modes 1006 and read from it until EOF. Used to show
* how reading from the MASTER side of a PIPE with the SLAVE side connected
* to a NEWCLI works.
*/
extern long Open(), Read();
#define NULL 0L
main(ac, av)
char *av[];
{
char buf[256];
long fh;
long n;
disablebreak();
if (av[1] == NULL) {
puts ("filename required... usually PIPE:a/tq");
puts ("Warning: you should have another CLI around");
puts ("in case you get caught so you can recover.");
exit(1);
}
fh = Open(av[1], 1006);
if (fh == NULL) {
puts ("Unable to open file or SLAVE part of pipe not active");
exit(1);
}
while ((n = Read(fh, buf, 256)) > 0)
write(1, buf, n);
Close(fh);
puts("Done");
}